<template>
	<ul>
		<li v-for="(item, index) in arr" :key="index">
			{{ item }}
			<button @click="arr.splice(index, 1)">删除</button>
		</li>
	</ul>
	<button @click="addNumber">生成</button>
</template>

<script setup>
import { reactive } from 'vue'
const arr = reactive([5, 10, 8])
const addNumber = () => {
	// 1.产生一个20以内的随机整数
	let number = Math.floor(20 * Math.random())
	// 2.将数字加到数组中
	arr.push(number)
}
</script>

<style scoped>
	
</style>